const express = require('express')
const Router = express.Router();
// var dbserver = require("../server/dbserver")
// var emailserver = require("../server/emailserver")
// Router.get('/test',(req,res)=>{
//     dbserver.finduser(res);
// })
// Router.post('/mail',(req,res)=>{
//     let sendmail = req.body.mail;
//     emailserver.emailSignUp(sendmail,res);
// })

const asignuser = require("../routerserver/asignuser")
const loginuser = require("../routerserver/loginuser")
const search = require("../routerserver/search")
const detail = require("../routerserver/detail")
const friend = require('../routerserver/friend')
const index = require('../routerserver/index')
const chart = require('../routerserver/chart')
const group = require('../routerserver/group')

Router.post("/siginup/add",asignuser.userAsign)//用户注册
Router.post("/siginup/judge",asignuser.judgeValue)//邮箱、名字判断
Router.post("/siginin/match",loginuser.userLogin)//登录

//搜索
Router.post("/search/searchinfo",search.searchInfo)//搜索信息
Router.post("/search/isfriend",search.isFriend)//是否为好友
// Router.post("/search/group",search.searchGroup)//搜索群
Router.post("/search/isingroup",search.isInGroup)//是否在群内

//详情和修改
Router.post("/user/detail",detail.userDetail)//用户详情
Router.post("/user/update",detail.userUpdate)//更新信息
Router.post("/user/updatemarkname",detail.updateFriendMarkName)//修改昵称
Router.post("/user/getmarkname",detail.getFriendMarkName)//获取昵称

//好友申请
Router.post("/friend/applyfriend",friend.applyFriend)//好友申请
Router.post("/friend/updatefriendstate",friend.updateFriendState)//同意
Router.post("/friend/deletefriend",friend.deleteFriend)//拒绝好友/删除好友


//首页（后续使用异步方法一次性获取主页数据）
Router.post("/index/getusers",index.getUsers)//按要求获取好友
// Router.post("/index/getonemsg",index.getOneMsg)//按要求获取一对一数据
// Router.post("/index/unreadmsg",index.unreadMsg)//获取未读消息
Router.post("/index/updatemsg",index.updateMsg)//修改消息状态
Router.post("/index/getgroups",index.getGroups)//按要求获取群列表和未读消息数
Router.post("/index/getgroupusers",index.getGroupUsers)//按要求获取群成员
Router.post("/index/updategroupmsg",index.updateGroupmsg)//修改群消息状态

//聊天页面
Router.post("/chart/msg",chart.msg)//分页获取数据一对一聊天数据
Router.post("/chart/groupmsg",chart.groupmsg)//分页获取数据群聊天数据

//群操作
//建群
Router.post("/group/creategroup",group.cteateGroup)//建群以及添加群成员
Router.post("/group/insertgroupmsg",group.insertGroupMsg)//写入群消息
Router.post("/group/groupdetail",group.groupDetail)//获取群信息
Router.post("/group/groupupdate",group.groupUpdate)//群详细信息修改
Router.post("/group/groupuserinfo",group.groupUserInfo)//群个人详细信息获取
Router.post("/group/groupuserupdate",group.groupUserUpdate)//群个人详细信息修改
Router.post("/group/deletegroupuser",group.deleteGroupUser)//删除群好友
Router.post("/group/deletegroup",group.deleteGroup)//删除群
Router.post("/group/addgroupuser",group.addGroupUser)//添加好友进群
Router.post("/group/outgroup",group.outGroup)//用户退出群
module.exports = Router;